Test-Series - programming logic

Test Number 10/15

Q: Select non linear data structures from the list of following data structures ! [Select appropriate options]
A. Array
B. Linked List
C. Trees
D. Graphs
Solution: The correct answers are:
Graphs,

Trees
Q: Tanuj writes the code for a function that takes as input n and calculates the sum of first n natural numbers.

//assume all header files are included

function sum(n)
{
if(??)
return 1
else
return
else
return(n+sum(n-1))
end
}

Fill in ?? in the code.
A. n equals 2
B. n > 1
C. n >= 1
D. n equals 1
Solution: The correct answer is:
n equals 1
Q: What does a compiler do?
A. Converts code from a high level language to a low level language
B. Converts code from a low level language to a high level language
C. Necessarily converts the code into assembly language
D. Necessarily converts the code into machine language
Solution: The correct answer is:
Converts code from a high level language to a low level language
Q: In _________ data structure , data contain hierarchical and network relationship between elements.
A. Linear
B. Non linear
C. bi-linear
D. tri-linear
Solution: The correct answer is:
Non linear
Q: If elements of the data structure forms a sequence of list then it is called as ____________.
A. Linear data structure
B. None of these
C. Primitive data structure
D. Primitive data structure
Solution: The correct answer is:
Linear data structure
Q: The for loop is equivalent to a while loop when
A. There is no initialization expression
B.  It is never equivalent
C. There is no increment expression
D. A and B combined are true
Solution: The correct answer is:
A and B combined are true
Q: How many times below for loop will be executed?

//assume all header  files are included

int main()
{
int i=0;
for(;;)
printf("%d,i");
return 0;
}
A. Infinite times
B. 1 times
C. 0 times
D. 10 times
Solution: The correct answer is:
Infinite times
Q: Geetika writes a piece of code, where a set of eight lines occur around 10 times in different parts of the program (Code A). She passes on the code to Deva. Deva puts the set of eight lines in a function definition and calls them at the 10 points in the program (Code B). Which code will run faster using an interpreter?
A. Code A and Code B will run with the same speed
B. None of these
C. Code B
D. Code A
Solution: The correct answer is:
Code A
Q: Which one of the following is the lowest level format to which the computer converts a higher language program before execution?
A. Assembly Language
B. System Language
C. English code
D. Machine Code
Solution: The correct answer is:
Machine Code

You Have Score    /9